/**
 * 
 */
package testy;

import poker.*;
import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * @author Administrator
 *
 */
public class EvaluateTest {

	static Table testTable;
	static Human testPlayer1, testPlayer2;
	static HandScore testHand1, testHand2;
	/**
	 * @throws java.lang.Exception
	 */
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		testTable = new Table(null);
		testPlayer1 = new Human(testTable);
		testPlayer2 = new Human(testTable);
	}

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		//testTable.deal();
		testPlayer1.reset();
		testPlayer2.reset();
	}

	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
	}

	/**
	 * Test method for {@link poker.Evaluate#getHandScore(poker.Player)}.
	 * @throws PokerException 
	 */
	@Test
	public void testGetHandScoreFlush() throws PokerException {
		testPlayer1.addCards(new Card(0,5), new Card(0,12), new Card(0,11), new Card(0,10), new Card(0,14));
		testHand1 = new HandScore(testPlayer1,HandScore.HN_FLUSH,14);
		
		assertEquals("Should have flush",Evaluate.getHandScore(testPlayer1).getHand(),testHand1.getHand());
	}
	
	@Test
	public void testGetHandScoreRoyalFlush() throws PokerException {
		testPlayer1.addCards(new Card(0,9), new Card(0,12), new Card(0,11), new Card(0,10), new Card(0,13));
		testHand1 = new HandScore(testPlayer1,HandScore.HN_STRAIGHT_FLUSH,14);
		
		assertEquals("Should have royal flush",Evaluate.getHandScore(testPlayer1).getHand(),testHand1.getHand());
	}
	
	@Test
	public void testGetHandScoreKickers() throws PokerException {
		testPlayer1.addCards(new Card(1,12), new Card(0,12), new Card(0,11), new Card(1,11), new Card(0,13));
		testHand1 = new HandScore(testPlayer1,HandScore.HN_TWO_PAIR,12,11,13);
		
		assertTrue("",Evaluate.getHandScore(testPlayer1).compareTo(testHand1) == 0);
	}
	
	@Test
	public void testGetHandScoreTieTwoPair() throws PokerException {
		testPlayer1.addCards(new Card(1,13), new Card(0,13), new Card(0,11), new Card(1,11), new Card(0,13));
		testPlayer2.addCards(new Card(2,12), new Card(3,12), new Card(2,11), new Card(3,11), new Card(2,14));
		
		assertTrue("",Evaluate.getHandScore(testPlayer1).compareTo(Evaluate.getHandScore(testPlayer2)) > 0);
	}
	
	@Test
	public void testGetHandScoreTieFlush() throws PokerException {
		testPlayer1.addCards(new Card(0,13), new Card(0,12), new Card(0,3), new Card(0,2), new Card(0,10));
		testPlayer2.addCards(new Card(2,12), new Card(2,3), new Card(2,10), new Card(2,2), new Card(2,13));
		
		assertTrue("",Evaluate.getHandScore(testPlayer1).compareTo(Evaluate.getHandScore(testPlayer2)) == 0);
	}
	
	@Test
	public void testGetHandScoreHighCard() throws PokerException {
		testPlayer1.addCards(new Card(0,13), new Card(2,12), new Card(0,3), new Card(3,2), new Card(0,10));
		testPlayer2.addCards(new Card(2,9), new Card(2,3), new Card(2,10), new Card(1,12), new Card(2,13));
		
		assertTrue("",Evaluate.getHandScore(testPlayer1).compareTo(Evaluate.getHandScore(testPlayer2)) < 0);
	}

	/**
	 * Test method for {@link poker.Evaluate#getScores(poker.Player[])}.
	 */
	@Test
	public void testGetScores() {
		//fail("Not yet implemented"); // TODO
	}

}
